import React, { Component } from 'react';
import ComC from './ComC'

class Unmount extends Component {
  constructor() {
    super();
    this.p3 = React.createRef();
    this.comc = React.createRef();
  }
  componentDidMount() {
    // console.log(this.refs.p1);
    console.log(this.comc);
    console.log(this.p2);
    console.log(this.p3);
  }
  render() {
    return (
      <div>
        <ComC ref={this.comc}></ComC>
        <p>REF的使用：先选择元素，然后操作元素。ref就是这个元素的指针，指向那个元素</p>
        <p>1. 字符串的方式</p>
        <p ref={(p2)=>this.p2=p2}>2. 回调函数的方式</p>
        <p ref={this.p3}>3.createRef API 的方式</p>
      </div>
    );
  }
}

export default Unmount;

